package entities;

import java.io.Serializable;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Transient;

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="DISC", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue(value="ROD")
public class Rodamiento implements Serializable{
	
	@Transient  
	private static final long serialVersionUID = 1L;

	private Integer id;
	private String codigo;
	private String caracteristicas;
	private String marca;
	private String origen;
	
	public Rodamiento(){
		
	}
	
	public Rodamiento(String codigoSKF) {
		super();
	}

	public Rodamiento(String origen, String marca, String codigo, String caracteristicas) {
		super();
		this.origen = origen;
		this.marca = marca;
		this.caracteristicas = caracteristicas;
		this.codigo = codigo;
	}
	
	public Rodamiento(RodamientoStock rodamientoStock){
		super();
		this.origen = rodamientoStock.getOrigen();
		this.marca = rodamientoStock.getMarca();
		this.caracteristicas = rodamientoStock.getCaracteristicas();
		this.codigo = rodamientoStock.getCodigo();
	}
	
	

	public void setId(Integer id) {
		this.id = id;
	}

	@Id 
    @GeneratedValue( strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	

	public String getMarca() {
		return marca;
	}

	public void setMarca(String marca) {
		this.marca = marca;
	}

	public String getOrigen() {
		return origen;
	}

	public void setOrigen(String origen) {
		this.origen = origen;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	public String getCodigo() {
		return codigo;
	}

	public void setCaracteristicas(String caracteristicas) {
		this.caracteristicas = caracteristicas;
	}

	public String getCaracteristicas() {
		return caracteristicas;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((caracteristicas == null) ? 0 : caracteristicas.hashCode());
		result = prime * result + ((codigo == null) ? 0 : codigo.hashCode());
		result = prime * result + ((marca == null) ? 0 : marca.hashCode());
		result = prime * result + ((origen == null) ? 0 : origen.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Rodamiento other = (Rodamiento) obj;
		if (caracteristicas != null && !"".equals(caracteristicas)) {
			if (other.caracteristicas == null) {
				return false;
			}else if (!caracteristicas.equals(other.caracteristicas)) {
				return false;
			}
		} 
		if (marca != null && !"".equals(marca)) {
			if (other.marca == null) {
				return false;
			}else if (!marca.equals(other.marca)) {
				return false;
			}
		}
		if (codigo != null && !"".equals(codigo)) {
			if (other.codigo == null) {
				return false;
			}else if (!codigo.equals(other.codigo)) {
				return false;
			}
		} 
		if (origen != null && !"".equals(origen)) {
			if (other.origen == null) {
				return false;
			}else if (!origen.equals(other.origen)) {
				return false;
			}
		} 
		return true;
	}

		

}
